home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
optivc32
/
mcfstd.h
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-06
|
31KB
|
590 lines
/* MCFstd.h
matrix management functions:
manipulations on matrices of data type "fComplex"
(single-precision complex numbers)
Copyright (c) 1996-1999 by Martin Sander
All Rights Reserved.
*/
#if !defined( __MATLIB_H )
#include <MatLib.h>
#endif
#if !defined( __VCFSTD_H )
#include <VCFstd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/************* Dynamic Generation of Matrices ************************/
cfMatrix __vf MCF_matrix( unsigned ht, unsigned len );
cfMatrix __vf MCF_matrix0( unsigned ht, unsigned len );
/* notice that, in the memory model HUGE,
neither len nor ht may exceed 4095 */
/***************************************************************************
* The following definitions ensure compatibility between dynamically *
* and statically allocated matrices. The definitions are somewhat *
* cumbersome, but the result for you is that you need not care about *
* the differences between the two types. *
* (Internally, the address of the first element of any matrix is needed; *
* the expression "MA[0]" is evaluated in a different way for both types, *
* but yields in either case the correct address to be passed to the *
* function you wish to call.) *
* Only in the rare case that you need to pass the address of one of *
* these functions as an argument to another function, you have to use *
* the actual run-time functions defined further below. Be careful with *
* this: future development of compilers may allow us to avoid this un- *
* handy scheme of macros. So future versions of MatrixLib may no longer *
* use these run-time names. *
***************************************************************************/
/*** Addressing single elements of dynamically allocated matrices: ******
These two functions are for compatibility with Pascal
(where elements of dynamically allocated matrices are not directly
accessible), and for getting around the pointer arithmetics bug in
some versions of Borland C++. */
#define MCF_Pelement( MA, ht, len, m, n ) MCFPelement( MA[0], ht, len, m, n )
/* returns a pointer to MA[m][n]. */
#define MCF_element( MA, ht, len, m, n ) *MCFPelement( MA[0], ht, len, m, n )
/* dereferenced pointer */
/**************** Initialization ***************************************
To initialize all elements of a matrix with the same value,
or to perform arithmetic operations on all elements simultaneously,
refer to the functions of VectorLib, declared in <VCFstd.h>, <VCFmath.h>.
In order to use the VectorLib functions, utilize the feature that
the whole matrix occupies one contiguous area in memory: pass the
address of the first row to the desired vector function, the size
of the "vector" being len * ht.
For example, initialize all elements of the matrix MA with {1.0, 0.0}
(this is *NOT* the identity matrix) by calling
VCF_equ1( MA[0], len * ht );
*/
#define MCF_equ1( MA, len ) MCFequ1( MA[0], len )
/* this is the identity matrix */
#define MCF_outerprod( MA, X, Y, ht, len ) MCFouterprod( MA[0], X, Y, ht, len )
/* sizX=ht, sizY=len */
#define MCF_Row_equC( MA, ht, len, iRow, C ) \
MCFRow_equC( MA[0], ht, len, iRow, C )
#define MCF_Col_equC( MA, ht, len, iCol, C ) \
MCFCol_equC( MA[0], ht, len, iCol, C )
#define MCF_Dia_equC( MA, len, C ) MCFDia_equC( MA[0], len, C )
#define MCF_Row_equV( MA, ht, len, iRow, X ) \
MCFRow_equV( MA[0], ht, len, iRow, X )
#define MCF_Col_equV( MA, ht, len, iCol, X ) \
MCFCol_equV( MA[0], ht, len, iCol, X )
#define MCF_Dia_equV( MA, len, X ) MCFDia_equV( MA[0], len, X )
#define MCF_equM( MB, MA, ht, len ) VCF_equV( MB[0], MA[0], ((ui)(len))*(ht) )
#define MCF_UequL( MA, len ) MCFUequL( MA[0], len )
#define MCF_LequU( MA, len ) MCFLequU( MA[0], len )
/* copy lower-diagonal elements into upper-diagonal
(or vice versa) by index-reflection, so as to
get a symmetric matrix */
/* data-type conversions: */
#define M_CEtoCF( MCF, MCE, ht, len ) V_CEtoCF( MCF[0], MCE[0], ((ui)ht)*len )
#define M_CFtoCE( MCE, MCF, ht, len ) V_CFtoCE( MCE[0], MCF[0], ((ui)ht)*len )
#define M_CDtoCF( MCF, MCD, ht, len ) V_CDtoCF( MCF[0], MCD[0], ((ui)ht)*len )
#define M_CFtoCD( MCD, MCF, ht, len ) V_CFtoCD( MCD[0], MCF[0], ((ui)ht)*len )
/******** Extracting a submatrix and copying a submatrix back *********/
#define MCF_submatrix( MSub, subHt, subLen, \
MSrce, srceHt, srceLen, \
firstRowInCol, sampInCol, firstColInRow, sampInRow ) \
MCFsubmatrix( MSub[0], subHt, subLen, \
MSrce[0], srceHt, srceLen, \
firstRowInCol, sampInCol, firstColInRow, sampInRow )
#define MCF_submatrix_equM( MDest, destHt, destLen, \
firstRowInCol, sampInCol, firstColInRow, sampInRow, \
MSrce, srceHt, srceLen ) \
MCFsubmatrix_equM( MDest[0], destHt, destLen, \
firstRowInCol, sampInCol, firstColInRow, sampInRow, \
MSrce[0], srceHt, srceLen )
/***** Extracting a single row or a single column or the diagonal ******
* and storing it into a vector */
#define MCF_Row_extract( Y, MA, ht, len, iRow ) \
MCFRow_extract( Y, MA[0], ht, len, iRow )
#define MCF_Col_extract( Y, MA, ht, len, iCol ) \
MCFCol_extract( Y, MA[0], ht, len, iCol )
#define MCF_Dia_extract( Y, MA, len ) MCFDia_extract( Y, MA[0], len )
/***************** Basic arithmetic operations *********************
performed on one single row,
or one single column of any matrix,
or on the diagonal of a square matrix
Note: In contrast to the analogous VectorLib functions, the operations
are performed in-place, i.e. the input matrix itself is changed */
#define MCF_Row_addC( MA, ht, len, iRow, C ) \
MCFRow_addC( MA[0], ht, len, iRow, C )
#define MCF_Col_addC( MA, ht, len, iCol, C ) \
MCFCol_addC( MA[0], ht, len, iCol, C )
#define MCF_Dia_addC( MA, len, C ) MCFDia_addC( MA[0], len, C )
#define MCF_Row_addV( MA, ht, len, iRow, X ) \
MCFRow_addV( MA[0], ht, len, iRow, X )
#define MCF_Col_addV( MA, ht, len, iCol, X ) \
MCFCol_addV( MA[0], ht, len, iCol, X )
#define MCF_Dia_addV( MA, len, X ) MCFDia_addV( MA[0], len, X )
#define MCF_Row_subC( MA, ht, len, iRow, C ) \
MCFRow_addC( MA[0], ht, len, iRow, (-C) )
#define MCF_Col_subC( MA, ht, len, iCol, C ) \
MCFCol_addC( MA[0], ht, len, iCol, (-C) )
#define MCF_Dia_subC( MA, len, C ) MCFDia_addC( MA[0], len, (-C) )
#define MCF_Row_subV( MA, ht, len, iRow, X ) \
MCFRow_subV( MA[0], ht, len, iRow, X )
#define MCF_Col_subV( MA, ht, len, iCol, X ) \
MCFCol_subV( MA[0], ht, len, iCol, X )
#define MCF_Dia_subV( MA, len, X ) MCFDia_subV( MA[0], len, X )
#define MCF_Row_subrC( MA, ht, len, iRow, C ) \
MCFRow_subrC( MA[0], ht, len, iRow, C )
#define MCF_Col_subrC( MA, ht, len, iCol, C ) \
MCFCol_subrC( MA[0], ht, len, iC